Skip to content

Validate that a Bedrock model or inference profile is available and enabled before attempting to use it#232

Merged
iansrobinson merged 3 commits intomainfrom
fix-bedrock-region-issue
Apr 30, 2026
Merged

Validate that a Bedrock model or inference profile is available and enabled before attempting to use it#232
iansrobinson merged 3 commits intomainfrom
fix-bedrock-region-issue

Conversation

@oussamahansal
Copy link
Copy Markdown
Collaborator

Issue #176

Description of changes:

  • Pre-flight check to validate the model id or cross-region inference model is available
  • fail in CFN templates on the condition that model is a geo-inferred model

resolves #176

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link
Copy Markdown

Lexical Graph Coverage Report: The coverage is at 45.9% (target: 80%). Download the HTML report here.

@github-actions
Copy link
Copy Markdown

Lexical Graph Coverage Report: The coverage is at 45.9% (target: 80%). Download the HTML report here.

@@ -795,97 +795,19 @@
"Fn::Sub": "arn:${AWS::Partition}:bedrock:*::foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it intentional to keep haiku 3.5 and sonnet 4.6?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss which model to keep across the project and open a separate issue for making the change to keep it consistent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it's only listed in IAM policies so the SageMaker notebook has permission to invoke it if a user chooses to

@iansrobinson
Copy link
Copy Markdown
Contributor

@oussamahansal The majority of integration tests are failing here with AccessDeniedException on the extraction side (the tests appear to be usingclaude-sonnet-4-20250514-v1, but without the requisite IAM permissions), and Wait timed out after 120 seconds on the query side.

@oussamahansal
Copy link
Copy Markdown
Collaborator Author

oussamahansal commented Apr 30, 2026

@iansrobinson Thanks for checking, I was able to reproduce it. The root cause is that the CFN templates hardcoded specific models in the IAM policy ARNs, the IAM role only grants the exact models listed in the template (anthropic.claude-sonnet-4-6.). If the test code or defaults reference a model that doesn't exactly match those ARNs, the call gets denied.

I fixed it by replacing the hardcoded per-model IAM ARNs with wildcards.
Before we had 6 Anthropic entries, each hardcoded:

foundation-model/anthropic.claude-3-5-haiku-20241022-v1:0
inference-profile/${regionPrefix}.anthropic.claude-3-5-haiku-20241022-v1:0
foundation-model/anthropic.claude-3-7-sonnet-20250219-v1:0
inference-profile/${regionPrefix}.anthropic.claude-3-7-sonnet-20250219-v1:0
foundation-model/anthropic.claude-sonnet-4-20250514-v1:0
inference-profile/${regionPrefix}.anthropic.claude-sonnet-4-20250514-v1:0

Now we have 2 wildcard entries:

foundation-model/anthropic.*
inference-profile/*.anthropic.*

Basically now any Anthropic model works without needing a template update, any inference profile prefix is covered.
The regionPrefix derivation which produces invalid ap in APAC regions was also removed.
I also upgraded the default model to anthropic.claude-sonnet-4-6.

Note: anthropic.claude-sonnet-4-20250514-v1:0 is now a legacy model in Bedrock. Some models are moving through their lifecycle rapidly, and new users who haven't actively used a legacy model won't have access to it. This is why I updated anthropic.claude-sonnet-4-6 as default and added wildcard IAM policies.

@github-actions
Copy link
Copy Markdown

Lexical Graph Coverage Report: The coverage is at 45.9% (target: 80%). Download the HTML report here.

@iansrobinson iansrobinson merged commit 3a45bbe into main Apr 30, 2026
9 checks passed
@oussamahansal oussamahansal deleted the fix-bedrock-region-issue branch May 1, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with region variables for using LLM in CloudFormation

3 participants